<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <style>
        .active{
            border: 1px solid red;
        }
        .text-danger{
            color:red;
        }
    </style>
</head>
<body>
    <div id="app">
        <div :class="{active:isActive,'text-danger':isDanger}">class对象语法</div>
        <div :class="obj">class对象语法</div>
    </div>    

    <script>
        var app = new Vue({
            el:"#app",
            data:{
                isActive:true,
                isDanger:true,
                // 不能动态切换
                // obj:{
                //     active:true,
                //     'text-danger':true
                // }
            },
            // 使用计算属性
            computed:{
                obj(){
                    return {
                        active:this.isActive,
                        'text-danger':this.isDanger

                    }
                }
            }
        });
    </script>
</body>
</html>